<?php
namespace Home\Controller;
use Think\Controller;
class AboutController extends Controller {
    /**
     * 关于我们列表
     */
    public function showlist() {
        $M_about = M('about');
        $about_list = $M_about->order('addtime DESC')->find();
        $this->about_list = $about_list;
        $this->display();
    }
    /**
     * 添加关于我们
     */
    /*public function add() {
        if(IS_POST) {
            $M_about = M('about');
            
            $data = I("post.");
            $data['addtime']    = date("Y-m-d H:i:s");
            $added = $M_about->add($data);
            
            if ($added){
                $this->success("添加成功", U("showlist"));
            } else {
                $this->error("添加失败");
            }
        }  else {
            $this->display();
        }
    }*/
    /**
     * 编辑关于我们
     */
    public function mod() {
        $M_about = M("about");
        if(IS_POST){
            $data   = I("post.");
            $data['addtime'] = date("Y-m-d H:i:s");
            //print_r($data);die;
            $moded  = $M_about->where("id = $data[id]")->save($data);
            if($moded){
                $this -> success("修改成功", U("showlist"));
            }else{
                $this -> error("修改失败");
            }
        } else {
            $id     = I('get.id');
            $data   = $M_about->where(array("id"=>$id))->find();
            $this->data = $data;
            $this->display();
        }
    }
    /**
     * 删除关于我们
     */
    /*public function del() {
        $M_about = M("about");
        $id = I("get.id");
        $del_row = $M_about->where(array('id'=>$id))->delete();
        if ($del_row) {
            $this->success("删除成功", U("showlist"));
        } else {
            $this->error("删除失败");
        }
    }*/
}